Skip to content

Fix/analyzer warning reduction batch#298

Merged
GeWuYou merged 9 commits into
mainfrom
fix/analyzer-warning-reduction-batch
Apr 27, 2026
Merged

Fix/analyzer warning reduction batch#298
GeWuYou merged 9 commits into
mainfrom
fix/analyzer-warning-reduction-batch

Conversation

@GeWuYou
Copy link
Copy Markdown
Owner

@GeWuYou GeWuYou commented Apr 27, 2026

Summary by CodeRabbit

发布说明

  • 重构
    • 优化了测试套件的组织结构,将测试辅助类提取到独立的专门文件中,提高了测试代码的可维护性和可复用性。

GeWuYou added 8 commits April 27, 2026 18:47
- 拆分 StateMachineTests 中的状态测试辅助类型到独立文件

- 补充提取后类型与扩展方法的 XML 文档说明

- 保持状态机测试行为不变并完成定向项目构建验证
- 拆分 DeterministicOrderNotification 与处理器到同目录独立文件以消除 MA0048

- 保留容器注册测试夹具行为与 XML 文档说明
- 拆分 TestObjectPool 与 TestPoolableObject 到 Pool 同目录独立文件

- 保留并补充对象池测试辅助类型的 XML 文档与命名空间一致性

- 验证 GFramework.Core.Tests Release 构建通过且当前切片无新增 warning
- 拆分 QueryCoroutineExtensionsTests 末尾的 IntQuery、ComplexQuery 与 ComplexResult 到同目录独立文件

- 补充 提取类型的 XML 文档并保持查询测试行为不变
- 拆分 TestEnvironment 到独立文件以消除 EnvironmentTests 的 MA0048 警告

- 补充 TestEnvironment 的 XML 文档并保留原有测试行为
- 拆分 EventBusTestsEvent 到独立文件以消除 EventBusTests.cs 的 MA0048 警告

- 补充提取事件类型的 XML 文档并保持 EventBusTests 行为不变
- 拆分 TestUnRegisterList 到独立文件以消除 MA0048

- 保留测试行为并补充测试替身的 XML 文档说明
- 拆分 GFramework.Core.Tests 中多组测试辅助类型到独立文件以消减 MA0048 warning

- 更新 analyzer-warning-reduction 的 tracking 与 trace 以记录批处理基线和下一恢复点

- 验证 GFramework.Core.Tests Release 构建清零并将仓库根权威 warning 基线压降到 288
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Warning

Rate limit exceeded

@GeWuYou has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 26 minutes and 57 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a3c8727e-5107-4205-bd82-342104ae52bb

📥 Commits

Reviewing files that changed from the base of the PR and between f0a36de and fbf8f9f.

📒 Files selected for processing (23)
  • GFramework.Core.Tests/Architectures/TestCommandWithResultV2.cs
  • GFramework.Core.Tests/Architectures/TestQueryV2.cs
  • GFramework.Core.Tests/Architectures/TrackingPipelineBehavior.cs
  • GFramework.Core.Tests/Coroutine/ComplexQuery.cs
  • GFramework.Core.Tests/Coroutine/TestTimeSource.cs
  • GFramework.Core.Tests/Environment/EnvironmentTests.cs
  • GFramework.Core.Tests/Environment/TestEnvironment.cs
  • GFramework.Core.Tests/Query/AbstractAsyncQueryTests.cs
  • GFramework.Core.Tests/Query/AsyncQueryExecutorTests.cs
  • GFramework.Core.Tests/Query/TestAsyncComplexQuery.cs
  • GFramework.Core.Tests/Query/TestAsyncComplexQueryV4.cs
  • GFramework.Core.Tests/Query/TestAsyncQueryInput.cs
  • GFramework.Core.Tests/Query/TestAsyncQueryResult.cs
  • GFramework.Core.Tests/Query/TestAsyncQueryResultV2.cs
  • GFramework.Core.Tests/State/StateMachineTests.cs
  • GFramework.Core.Tests/State/TestAsyncState.cs
  • GFramework.Core.Tests/State/TestStateMachineSystemV5.cs
  • GFramework.Core.Tests/State/TestStateV5_2.cs
  • GFramework.Core.Tests/Utility/AbstractContextUtilityTests.cs
  • GFramework.Core.Tests/Utility/TestContextUtilityV1.cs
  • GFramework.Core.Tests/Utility/TestContextUtilityV2.cs
  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
  • ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
📝 Walkthrough

Walkthrough

大规模重构GFramework.Core.Tests中的测试辅助类,将其从各自的测试文件中提取到独立的类文件中,以改进代码组织结构。这涉及60+个新文件创建和相应的测试文件修改。

Changes

Cohort / File(s) Summary
Architecture Tests
GFramework.Core.Tests/Architectures/AdditionalAssemblyNotification.cs, AdditionalAssemblyNotificationHandlerRegistry.cs, AdditionalAssemblyNotificationHandlerState.cs, ModuleBehaviorRequest.cs, ModuleBehaviorRequestHandler.cs, TrackingPipelineBehavior.cs, TestCommandV2.cs, TestCommandWithResultV2.cs, TestEventV2.cs, TestModelV2.cs, TestQueryV2.cs, TestSystemV2.cs, TestUtilityV2.cs
ArchitectureAdditionalCqrsHandlersTests.csArchitectureContextTests.cs中提取85个测试辅助类行到13个新文件中,以支持架构和CQRS处理程序注册验证。
Command Tests
GFramework.Core.Tests/Command/TestCommand.cs, TestCommandInput.cs, TestCommandInputV2.cs, TestCommandWithResult.cs, TestAsyncCommand.cs, TestAsyncCommandWithResult.cs, TestAsyncCommandV3.cs, TestAsyncCommandWithExceptionV3.cs, TestAsyncCommandChildV3.cs, TestAsyncCommandWithResultChildV3.cs
CommandExecutorTests.csAbstractAsyncCommandTests.cs中提取142-168行的5种命令变体到10个新文件中,用于异步/同步命令执行测试。
Coroutine Tests
GFramework.Core.Tests/Coroutine/IntQuery.cs, ComplexQuery.cs, ComplexResult.cs, TestTimeSource.cs
QueryCoroutineExtensionsTests.csCoroutineSchedulerTests.cs中提取60行和25行的查询/时间源实现到4个新文件中。
Cqrs Tests
GFramework.Core.Tests/Cqrs/DeterministicOrderNotification.cs
新增CQRS通知测试类型,支持容器层测试的确定性顺序验证。
Environment Tests
GFramework.Core.Tests/Environment/TestEnvironment.cs
EnvironmentTests.cs中提取28行环境实现到独立文件中。
Events Tests
GFramework.Core.Tests/Events/EventBusTestsEvent.cs
EventBusTests.cs中提取7行事件类型到新文件中。
Extensions Tests
GFramework.Core.Tests/Extensions/TestClass.cs, TestUnRegisterList.cs
ObjectExtensionsTests.csUnRegisterListExtensionTests.cs中提取16-12行的测试辅助类到2个新文件中。
Pool Tests
GFramework.Core.Tests/Pool/TestObjectPool.cs, TestPoolableObject.cs
ObjectPoolTests.cs中提取80行的对象池实现到2个新文件中。
Query Tests
GFramework.Core.Tests/Query/TestQueryInput.cs, TestQuery.cs, TestStringQuery.cs, TestAsyncQueryInput.cs, TestAsyncQuery.cs, TestAsyncStringQuery.cs, TestAsyncBooleanQuery.cs, TestAsyncComplexQuery.cs, TestAsyncQueryWithException.cs, TestAsyncQueryResult.cs
QueryExecutorTests.csAsyncQueryExecutorTests.cs中提取157行的6种查询变体到10个新文件中,覆盖同步和异步查询执行。
Rule Tests
GFramework.Core.Tests/Rule/TestContextAware.cs
ContextAwareTests.cs中提取26行的上下文感知状态实现到独立文件中。
State Tests
GFramework.Core.Tests/State/ConcreteStateV2.cs, ConcreteStateV3.cs, ConcreteStateV4.cs, ConditionalStateV2.cs, TrackingStateV2.cs, ConcreteAsyncStateV2.cs, TestAsyncState.cs, TestStateV2.cs, TestStateV3.cs, TestStateV4.cs, TestStateV5.cs, TestStateV5_2.cs, TestContextAwareStateV5.cs, TestContextAwareStateV5_2.cs, TestStateMachineSystemV5.cs, StateMachineExtensions.cs
StateTests.csStateMachineTests.csStateMachineSystemTests.cs中提取406+235+138行的16个状态机实现到对应的新文件中,支持同步/异步状态转换和上下文感知状态测试。
Utility Tests
GFramework.Core.Tests/Utility/TestContextUtilityV1.cs, TestContextUtilityV2.cs
AbstractContextUtilityTests.cs中提取85行的2个上下文实用程序实现到新文件中。
Documentation
ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md, traces/analyzer-warning-reduction-trace.md
更新分析器警告减少跟踪文档,记录RP-085阶段的执行结果,显示GFramework.Core.Tests警告从353降至0,仓库总体警告从353降至288。

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title "Fix/analyzer warning reduction batch" is directly related to the main change in the changeset, which focuses on refactoring and reorganizing test helper types across multiple test files to reduce analyzer warnings.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/analyzer-warning-reduction-batch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2159 2159 0 0 0 0 36.1s    ↓662ms

Test Results

passed 2159 passed

Details

tests 2159 tests
clock 36.1s ↓662ms
tool nunit
build CI - Build & Test arrow-right build-and-test link #995
pull-request Fix/analyzer warning reduction batch link #298

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2150 0 3 4.7s

Fail Rate

Fail Rate 0.00%
Test 📝 Results 📊 Passed ✅ Failed ❌ Fail Rate (%) 📈
ILogAppender_Flush_Should_Raise_OnFlushCompleted_Only_Once 38 37 1 2.63    ↓0.07
RegisterMigration_During_Cache_Rebuild_Should_Not_Leave_Stale_Type_Cache 45 44 1 2.22    ↓0.05
Run_Should_Assign_Globally_Unique_Reference_Metadata_Member_Names 46 45 1 2.17    ↓0.05

build-and-test: Run #995

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
2159 2159 0 0 0 0 0 36.1s

🎉 All tests passed!

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
SendRequestAsync_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 46 4.1s 4.7s
Does_Not_Report_When_FieldInjectedModel_Is_Registered 46 2.2s 2.4s
Generates_Scene_Behavior_Boilerplate 46 1.9s 2.0s
CleanupDuringAcquire_Should_NotCauseRaceCondition 46 1.1s 1.1s
Append_ShouldNotBlock 46 1.0s 1.0s
Flush_Should_Raise_OnFlushCompleted_With_Sender_And_Result 39 52ms 1.0s
Context_Caching_Should_Improve_Performance 46 781ms 791ms
PendingCount_ShouldReflectQueuedEntries 46 501ms 501ms
Cleanup_Should_NotRemoveActiveLocks 46 404ms 406ms
Cleanup_Should_RemoveUnusedLocks 46 401ms 402ms

± Comparison with run #994 at 1ced304 | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 46 runs.

Github Test Reporter by CTRF 💚

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR refactors test helper classes out of test files and into their own dedicated files across GFramework.Core.Tests, reducing MA0048 analyzer warnings from 353 to 288 unique positions. A few semantic corrections are bundled in: DoubleValueTripleValue (the computed value was always input.Value * 3), TestEnvironment.RegisterRegisterForTest (removes the new-hiding of the base method), and AllowTransitionAllowTransitions for TestAsyncState.

Confidence Score: 5/5

Safe to merge — all changes are test-only reorganization with no production code impact; 1610 tests pass.

All findings are P2 style suggestions (naming consistency). No logic errors, no production code touched, and the tracking doc confirms a clean Release build with 1610 passing tests.

GFramework.Core.Tests/State/TestStateV2.cs — minor AllowTransition vs AllowTransitions naming inconsistency worth aligning.

Important Files Changed

Filename Overview
GFramework.Core.Tests/Query/TestAsyncQueryResultV2.cs Renames DoubleValue → TripleValue to match the actual computation (×3); all call sites updated consistently.
GFramework.Core.Tests/Environment/TestEnvironment.cs Extracted from EnvironmentTests.cs; Register() renamed RegisterForTest() to avoid hiding the base-class method via new.
GFramework.Core.Tests/State/TestStateV2.cs New dedicated file; property is AllowTransition (singular) while peer classes TestAsyncState/ConcreteStateV2/ConcreteAsyncStateV2 use AllowTransitions (plural).
GFramework.Core.Tests/State/TestAsyncState.cs Extracted from StateMachineTests.cs; uses AllowTransitions and throws on sync entry points to guard async-only paths.
GFramework.Core.Tests/Architectures/AdditionalAssemblyNotificationHandlerRegistry.cs Extracted from ArchitectureAdditionalCqrsHandlersTests.cs; logic unchanged, now properly namespaced in its own file.
GFramework.Core.Tests/Query/TestAsyncComplexQueryV4.cs Updated DoubleValue → TripleValue to match the renamed property in TestAsyncQueryResultV2.
GFramework.Core.Tests/State/ConcreteStateV2.cs Extracted from StateTests.cs; uses AllowTransitions (plural), consistent with other async/concrete state helpers.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Test files before PR\ntest class + helper classes in same file] -->|Extract helper types| B[Test class file\ntest logic only]
    A -->|Create dedicated files| C[Helper class files\none type per file]
    B --> D[Reduces MA0048 warnings]
    C --> D
    D --> E[Warning count: 353 → 288]

    subgraph Semantic Fixes
        F[DoubleValue → TripleValue\naccurate naming for x3]
        G[Register → RegisterForTest\nremoves base method hiding]
        H[AllowTransition → AllowTransitions\nin TestAsyncState]
    end
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: GFramework.Core.Tests/State/TestStateV2.cs
Line: 13

Comment:
**Inconsistent property name vs peer classes**

`AllowTransition` (singular) here differs from `AllowTransitions` (plural) used by `ConcreteStateV2`, `TestAsyncState`, and `ConcreteAsyncStateV2`. Aligning the name improves readability when tests mix these classes side-by-side.

```suggestion
    public bool AllowTransitions { get; set; } = true;
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "fix(core-tests): 收敛PR298的nitpick问题" | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
⚠️ CSHARP dotnet-format yes 1 no 5.91s
✅ REPOSITORY gitleaks yes no no 7.48s
✅ REPOSITORY trufflehog yes no no 6.17s

Detailed Issues

⚠️ CSHARP / dotnet-format - 1 error
Welcome to .NET 9.0!
---------------------
SDK Version: 9.0.114

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, run 'dotnet dev-certs https --trust'
Learn about HTTPS: https://aka.ms/dotnet-https

----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Unhandled exception: System.Exception: Restore operation failed.
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.OpenMSBuildWorkspaceAsync(String solutionOrProjectPath, WorkspaceType workspaceType, Boolean noRestore, Boolean requiresSemantics, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
   at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
   at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (18)
GFramework.Core.Tests/Coroutine/TestTimeSource.cs (1)

8-8: 建议将类声明为 sealed

该测试辅助类不存在被继承的设计意图,建议加上 sealed 修饰符,符合 Meziantou.Analyzer (MA0053) 的常见建议,避免后续被意外派生。

♻️ 建议改动
-public class TestTimeSource : ITimeSource
+public sealed class TestTimeSource : ITimeSource

As per coding guidelines: "Treat Meziantou.Analyzer feedback as part of the coding standard in C#"。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Coroutine/TestTimeSource.cs` at line 8, The
TestTimeSource class implements ITimeSource but has no intended inheritance;
mark the class declaration as sealed (change "public class TestTimeSource :
ITimeSource" to "public sealed class TestTimeSource : ITimeSource") so it cannot
be derived, satisfying Meziantou.Analyzer MA0053 and preventing accidental
subclassing.
GFramework.Core.Tests/State/TestStateMachineSystemV5.cs (1)

16-20: XML 文档与返回类型不一致:IDictionary 并非只读视图。

第 16 行注释声明返回值为"状态类型到状态实例的只读视图",但 IDictionary<Type, IState> 是可变接口,调用方仍可通过返回值修改内部 States,从而破坏被测系统的状态。建议要么将返回类型收紧为 IReadOnlyDictionary<Type, IState>,要么更新 XML 文档以如实描述返回的是可变映射。

♻️ 建议修改(收紧为只读视图)
-    /// <returns>状态类型到状态实例的只读视图。</returns>
-    public IDictionary<Type, IState> GetStates()
+    /// <returns>状态类型到状态实例的只读视图。</returns>
+    public IReadOnlyDictionary<Type, IState> GetStates()
     {
         return States;
     }

注:若 States 的运行时类型为 Dictionary<Type, IState>,可直接隐式实现 IReadOnlyDictionary<,>;否则可使用 new ReadOnlyDictionary<Type, IState>(...) 包装,或者在该测试场景中确实需要可变性时,反过来修正注释。

As per coding guidelines: "Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs",此处公共 API 文档与实际语义不符,应保持一致。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/State/TestStateMachineSystemV5.cs` around lines 16 -
20, The XML docs claim GetStates returns a read-only view but the method returns
IDictionary<Type, IState> (which is mutable) and exposes the internal States
field; change the API to return IReadOnlyDictionary<Type, IState> from GetStates
and return States directly if States implements IReadOnlyDictionary or wrap
States with a ReadOnlyDictionary<Type, IState> (or alternatively, if mutability
is intended, update the XML comment to describe a mutable mapping). Update the
GetStates method signature and its return expression to use
IReadOnlyDictionary<Type, IState> and ensure the States member is not exposed
mutably.
GFramework.Core.Tests/Architectures/TestQueryV2.cs (1)

1-44: LGTM!

TestQueryV2 作为 IQuery<int> 的测试桩实现简洁清晰,Result 使用 init 访问器保证测试构造时设置不可变值,行为可预测;XML 文档与命名/格式约定均满足规范。

一个小提示(可选):Line 14 处 Result 属性的 <summary> 写的是“获取或设置查询返回值”,但实际只暴露 init,不可在构造后被设置。是否考虑改为“获取查询返回值(构造时通过对象初始化器设置)”以更准确反映语义?同样的措辞在 TestCommandWithResultV2.Result 中也存在。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Architectures/TestQueryV2.cs` around lines 1 - 44,
Update the XML <summary> for the Result property on TestQueryV2 to reflect that
it is init-only (settable only during object initialization) rather than
read/write; locate the Result property in class TestQueryV2 and rephrase its
summary to something like "Gets the query result (set via object initializer
during construction)". Also apply the same wording change to
TestCommandWithResultV2.Result so both summaries accurately describe their
init-only semantics.
GFramework.Core.Tests/Utility/TestContextUtilityV2.cs (1)

15-18: 建议将 Destroyed 改为 private set,与其他生命周期标记属性保持一致。

InitializedCustomInitializationDone 均使用 private set,仅由 OnDestroy / OnInit 内部更新;而 Destroyed 暴露了公共 setter,会让外部测试代码可以随意篡改销毁状态,掩盖真实的生命周期触发情况,造成断言失真。建议统一收敛为 private set

♻️ 建议的修改
-    /// <summary>
-    ///     获取或设置一个值,该值指示当前工具是否已执行销毁逻辑。
-    /// </summary>
-    public bool Destroyed { get; set; }
+    /// <summary>
+    ///     获取一个值,该值指示当前工具是否已执行销毁逻辑。
+    /// </summary>
+    public bool Destroyed { get; private set; }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Utility/TestContextUtilityV2.cs` around lines 15 - 18,
The Destroyed property currently has a public setter which allows external code
to mutate lifecycle state; change its definition to use a private setter (i.e.,
public bool Destroyed { get; private set; }) to match Initialized and
CustomInitializationDone, and ensure all assignments to Destroyed remain inside
the lifecycle methods (e.g., OnDestroy) so only internal logic updates the flag.
GFramework.Core.Tests/Utility/TestContextUtilityV1.cs (2)

16-19: 建议将 Destroyed 改为 private set,与同类型其他生命周期标记保持一致。

InitializedInitCalled 均为 private set,唯独 Destroyed 暴露公共 setter。作为生命周期断言桩,外部修改这些标记只会引入误导性的测试通过/失败结果。建议统一收敛为 private set,让标记仅由重写的 OnDestroy 设置。

♻️ 建议的修改
-    /// <summary>
-    ///     获取或设置一个值,该值指示当前工具是否已执行销毁逻辑。
-    /// </summary>
-    public bool Destroyed { get; set; }
+    /// <summary>
+    ///     获取一个值,该值指示当前工具是否已执行销毁逻辑。
+    /// </summary>
+    public bool Destroyed { get; private set; }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Utility/TestContextUtilityV1.cs` around lines 16 - 19,
The Destroyed property currently has a public setter while similar lifecycle
flags Initialized and InitCalled use private setters; change the Destroyed
auto-property to use a private set (i.e., public bool Destroyed { get; private
set; }) so only the class can modify it, and ensure the lifecycle method
OnDestroy (or the override responsible for teardown) sets Destroyed internally
rather than relying on external callers to mutate it.

11-24: InitializedInitCalled 语义重复。

二者在 OnInit 中被同时置为 true,且无任何独立路径会单独翻转其中一个,导致它们对断言而言是等价的冗余信号。如果测试目的不同(例如一个表示 “基类 Init 入口被进入”,另一个表示 “自定义 OnInit 钩子被调用”),建议在两个属性的 XML 注释中明确说明区别;否则建议合并为单一属性以避免误用。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Utility/TestContextUtilityV1.cs` around lines 11 - 24,
属性 Initialized 和 InitCalled 在 OnInit 中总被同时置为 true 且语义重复;请在 TestContextUtilityV1
中要么合并为单一属性(例如保留 Initialized 并删除 InitCalled,更新所有使用 InitCalled 的断言和引用为
Initialized),要么在 XML 注释中明确区分两者的语义(例如 一个表示“基类入口已执行”,另一个表示“派生/自定义 OnInit
钩子已调用”),并更新 OnInit 实现或测试路径以使两个属性能在语义上独立翻转;参照标识符:Initialized、InitCalled、OnInit
进行定位并同步修改所有相关引用和注释。
GFramework.Core.Tests/Coroutine/ComplexQuery.cs (1)

44-47: GetContext() 使用 _context! 抑制了可空告警,建议显式校验。

按编码规范应"编写遵循可空注解的空安全代码,而不是默认抑制告警"。当测试用例忘记调用 SetContext 时,当前实现会向调用方返回 null,再在远端触发 NullReferenceException,不利于排查。建议改为显式抛出,让失败信息更清晰;或将 GetContext 的返回类型改为可空。

♻️ 建议改动
     public IArchitectureContext GetContext()
     {
-        return _context!;
+        return _context ?? throw new InvalidOperationException(
+            $"{nameof(SetContext)} must be called before {nameof(GetContext)}.");
     }

As per coding guidelines: "Write null-safe code that respects nullable annotations instead of suppressing warnings by default".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Coroutine/ComplexQuery.cs` around lines 44 - 47,
GetContext currently suppresses nullable warnings with _context! which can hide
a missed SetContext call; change GetContext to explicitly check _context for
null and either (preferred) throw an informative InvalidOperationException
(e.g., "Context not initialized. Call SetContext before using.") or, if you
prefer API change, make GetContext return IArchitectureContext? to reflect
nullability; update callers/tests accordingly. Ensure the check references the
field _context and the method GetContext (and mention SetContext in the
exception message) so failures are clear and null-safety is preserved.
GFramework.Core.Tests/State/TestStateV5_2.cs (1)

20-23: 建议显式消费未使用参数以避免分析器告警

这 3 个接口实现方法里参数均未使用,容易产生“unused parameter”告警;建议显式赋值给 discard,保留当前语义同时降低噪音。

♻️ 建议修改
 public bool CanTransitionTo(IState next)
 {
+    _ = next;
     return true;
 }

 public void OnEnter(IState? previous)
 {
+    _ = previous;
 }

 public void OnExit(IState? next)
 {
+    _ = next;
 }

As per coding guidelines, “Treat Meziantou.Analyzer feedback as part of the coding standard in C#.”

Also applies to: 29-39

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/State/TestStateV5_2.cs` around lines 20 - 23, The
parameter 'next' in CanTransitionTo(IState next) (and the other two
IState-taking interface implementations in TestStateV5_2) is unused and triggers
analyzer warnings; explicitly consume the parameter by assigning it to a discard
(e.g. "_ = next;") at the start of each method to preserve current behavior
while silencing the unused-parameter warning, leaving the return logic unchanged
and keeping the methods as the interface implementations.
ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md (1)

21-23: 建议去重重复的验证记录以保持恢复文档精简

Line 21-23 与 Line 29-30 记录了同一条 GFramework.Core.Tests Release 构建结果,建议保留一次并在同一条目下补充必要说明,减少 active 文档噪音。

As per coding guidelines, "Active tracking and trace files are recovery entrypoints... MUST stay concise enough for boot to locate the current recovery point quickly."

Also applies to: 29-30

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md`
around lines 21 - 23, The file contains duplicated verification entries for the
same build command `dotnet build
GFramework.Core.Tests/GFramework.Core.Tests.csproj -c Release` (also noted at
the later entry that starts with the same command); remove the duplicate by
keeping a single consolidated entry for `GFramework.Core.Tests` Release build,
merge any differing notes (e.g., result: "成功;0 Warning(s)、0 Error(s)") into that
one entry, and drop the redundant block (the later `dotnet build`/`dotnet clean`
lines) so the active recovery document stays concise and unambiguous.
GFramework.Core.Tests/Command/TestAsyncCommand.cs (1)

5-7: XML 文档 cref 引用建议补充。

根据 PR 摘要,TestAsyncCommand 同时供 CommandExecutorTestsAbstractAsyncCommandTests 使用,建议在 <summary> 中一并体现,使文档与实际复用范围保持一致。

📝 建议的文档调整
 /// <summary>
-///     表示 <see cref="CommandExecutorTests" /> 使用的异步测试命令。
+///     表示 <see cref="CommandExecutorTests" /> 与 <see cref="AbstractAsyncCommandTests" /> 使用的异步测试命令。
 /// </summary>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Command/TestAsyncCommand.cs` around lines 5 - 7, Update
the XML <summary> for the TestAsyncCommand class to mention both consumers
(CommandExecutorTests and AbstractAsyncCommandTests) and adjust the cref
references accordingly so the documentation reflects actual reuse; specifically
edit the XML summary that currently references <see cref="CommandExecutorTests"
/> to include or replace with both <see cref="CommandExecutorTests" /> and <see
cref="AbstractAsyncCommandTests" /> (or reword to "used by CommandExecutorTests
and AbstractAsyncCommandTests") so the cref links point to the two test classes
and the summary matches real usage of TestAsyncCommand.
GFramework.Core.Tests/Command/TestAsyncCommandWithResult.cs (1)

5-7: XML 文档 cref 引用建议补充。

按照 PR 摘要,此异步命令同样会被 AbstractAsyncCommandTests 引用,但 <summary> 仅提到 CommandExecutorTests。如同时被多个测试套件复用,建议在文档中一并提及(或泛化措辞),避免后续阅读时产生误解。

📝 建议的文档调整
 /// <summary>
-///     表示 <see cref="CommandExecutorTests" /> 使用的带返回值异步测试命令。
+///     表示 <see cref="CommandExecutorTests" /> 与 <see cref="AbstractAsyncCommandTests" /> 使用的带返回值异步测试命令。
 /// </summary>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Command/TestAsyncCommandWithResult.cs` around lines 5 -
7, 更新 TestAsyncCommandWithResult 类的 XML 文档注释,将 <summary> 中对 <see
cref="CommandExecutorTests" /> 的专属引用扩展为同时包含 <see
cref="AbstractAsyncCommandTests" />
或改为泛化表述以表明此异步命令被多个测试套件复用;定位符号:TestAsyncCommandWithResult 类的类级注释(当前含 <summary> 和
<see cref="CommandExecutorTests" />),把 cref 改为 "<see cref="CommandExecutorTests"
/>, <see cref="AbstractAsyncCommandTests" />" 或改写为“用于多个异步命令测试(例如
CommandExecutorTests 和 AbstractAsyncCommandTests)”。
GFramework.Core.Tests/Architectures/TrackingPipelineBehavior.cs (1)

16-31: 静态计数器存在线程安全与测试隔离隐患

InvocationCount 是泛型类型的静态可变状态,InvocationCount++ 并非原子操作。若 NUnit 以并行模式运行(或后续启用 [Parallelizable]),共享相同 TRequest/TResponse 闭合类型的多个测试同时触发该行为时会出现计数丢失或竞态。同时该计数器在测试间不会自动重置,依赖各测试自行清零,容易因执行顺序导致脆弱断言。

建议至少使用 Interlocked.Increment 保障原子性,并在 XML 注释中明确线程安全前提与重置约定(例如要求测试在 [SetUp] 中重置)。

♻️ 建议的最小化修复
     /// <summary>
     ///     获取当前测试进程中该请求类型对应的行为触发次数。
+    ///     注意:该计数器为进程内静态共享状态,需要测试自行在 SetUp 中重置;
+    ///     自增使用 <see cref="Interlocked.Increment(ref int)"/> 以避免并行测试下的竞态。
     /// </summary>
-    public static int InvocationCount { get; set; }
+    private static int _invocationCount;
+    public static int InvocationCount
+    {
+        get => Volatile.Read(ref _invocationCount);
+        set => Volatile.Write(ref _invocationCount, value);
+    }
@@
-        InvocationCount++;
+        Interlocked.Increment(ref _invocationCount);
         return await next(message, cancellationToken).ConfigureAwait(false);

As per coding guidelines: "When adding caching, pooling, or shared mutable state, document thread-safety assumptions and failure modes in C#"。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Architectures/TrackingPipelineBehavior.cs` around lines
16 - 31, InvocationCount is a static mutable counter on the generic
TrackingPipelineBehavior and incrementing it with InvocationCount++ is not
atomic and causes races and test isolation problems; change the increment in
Handle to use Interlocked.Increment(ref InvocationCount) to make it atomic,
update the XML comments on InvocationCount and the Handle method to state the
thread-safety guarantees and that tests must reset InvocationCount (e.g., in a
[SetUp] method) before each test, and ensure InvocationCount remains an int so
Interlocked.Increment can be used.
GFramework.Core.Tests/Query/TestAsyncQueryResult.cs (1)

8-16: XML 文档措辞与 init 访问器不一致(可选优化)

ValueDoubleValue 均为 init-only 属性,仅能在对象初始化时赋值,但 <summary> 描述为“获取或设置”。建议改为“获取”或“获取并初始化”,以更准确地反映属性语义。TestAsyncQueryInput.cs 中的 Value 属性同理。

📝 建议修改
     /// <summary>
-    ///     获取或设置主结果值。
+    ///     获取主结果值。
     /// </summary>
     public int Value { get; init; }

     /// <summary>
-    ///     获取或设置派生的双重结果值。
+    ///     获取派生的双重结果值。
     /// </summary>
     public int DoubleValue { get; init; }

As per coding guidelines: "All public, protected, and internal types and members MUST include XML documentation comments..." — 此处属于已有注释的语义准确性微调。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Query/TestAsyncQueryResult.cs` around lines 8 - 16,
Update the XML summaries to reflect that the properties are init-only: change
the <summary> for the properties Value and DoubleValue in TestAsyncQueryResult
(and the Value property in TestAsyncQueryInput.cs) from wording like "获取或设置" to
"获取" or "获取并初始化" so the docs accurately describe that these are assignable only
at initialization; locate the properties named Value and DoubleValue and adjust
their <summary> text accordingly.
GFramework.Core.Tests/Query/TestAsyncComplexQuery.cs (1)

23-32: DoubleValue 字段名与赋值语义存在轻微误导(可选)

OnDoAsync 中将 DoubleValue 赋值为 input.Value * 3,但 TestAsyncQueryResult.DoubleValue 的 XML 注释为“派生的双重结果值”,且字段名暗示“double/双倍”。命名/赋值不一致虽不影响测试断言(只要测试断言写为 *3),但容易在后续维护中造成困惑。

如果该断言确实期望三倍值,建议把 DoubleValue 改名为更中性的名字(例如 TripleValueSecondaryValue);如果应当为双倍,则将此处改为 input.Value * 2(但需要与现有结果属性 Value 区分,避免重复)。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Query/TestAsyncComplexQuery.cs` around lines 23 - 32,
The TestAsyncQueryResult.DoubleValue name and its assignment in OnDoAsync
(currently input.Value * 3) are semantically inconsistent; change the API to be
clear by renaming TestAsyncQueryResult.DoubleValue to TripleValue (update its
XML comment accordingly) and adjust all references and tests to use TripleValue,
or alternatively change the assignment in OnDoAsync to input.Value * 2 if you
intend it to be a true “double” (make the same change in the
TestAsyncQueryResult XML comment and any tests); locate the symbols
TestAsyncQueryResult, its DoubleValue property, and the
OnDoAsync(TestAsyncQueryInput) implementation to apply the change.
GFramework.Core.Tests/Command/TestAsyncCommandWithExceptionV3.cs (1)

24-27: 可选:在异步签名中以 Task.FromException 返回故障任务(可忽略)。

当前在返回 Task 的方法体内同步 throw,对调用方 await 而言行为等价(异常会被 await 解包)。仅为风格统一,可考虑改为 Task.FromException,让"异步方法返回故障任务"更显式;如保留同步抛出以专门验证早期/同步异常路径,则当前写法也是合理的,无需修改。

♻️ 可选改写
-    protected override Task OnExecuteAsync(TestCommandInputV2 input)
-    {
-        throw new InvalidOperationException("Test exception");
-    }
+    protected override Task OnExecuteAsync(TestCommandInputV2 input)
+    {
+        return Task.FromException(new InvalidOperationException("Test exception"));
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Command/TestAsyncCommandWithExceptionV3.cs` around
lines 24 - 27, 当前在 TestAsyncCommandWithExceptionV3.cs 的
OnExecuteAsync(TestCommandInputV2) 中同步 throw
异常,若要将“异步方法返回故障任务”写得更显式,请把同步抛出替换为返回一个故障任务,例如将 throw new
InvalidOperationException(...) 改为 return Task.FromException(new
InvalidOperationException(...)),以使 OnExecuteAsync 明确返回失败的
Task;如果你想保留同步抛出以测试同步异常路径,则无需修改。
GFramework.Core.Tests/State/TestAsyncState.cs (1)

13-13: 命名建议:与 ConcreteAsyncStateV2.AllowTransitions 保持一致。

TestAsyncState 暴露的是 AllowTransition(单数),而同目录下 ConcreteAsyncStateV2 使用 AllowTransitions(复数)。两者语义相同,统一命名可减少在测试中切换两类桩对象时的心智负担。建议将本类改为 AllowTransitions 以对齐。

♻️ 建议改动
-    public bool AllowTransition { get; set; } = true;
+    public bool AllowTransitions { get; set; } = true;

并相应更新 CanTransitionToAsync 中的引用:

-        return AllowTransition;
+        return AllowTransitions;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/State/TestAsyncState.cs` at line 13, Rename the
TestAsyncState property AllowTransition to AllowTransitions to match
ConcreteAsyncStateV2.AllowTransitions; update all references within the class
(notably the CanTransitionToAsync method) to use AllowTransitions and adjust any
test fixtures or usages that construct or inspect TestAsyncState so they compile
and maintain behavior.
GFramework.Core.Tests/State/ConcreteStateV4.cs (1)

1-59: ConcreteStateV4ConcreteStateV3 完全重复,建议合并。

两个类的字段集合(EnterCalled/ExitCalled/EnterFrom/ExitTo)、OnEnter/OnExit 实现以及恒返回 trueCanTransitionTo 完全一致,仅类名不同。提取测试辅助类的初衷是便于复用,再保留两个完全相同的类反而稀释了这一收益。

如果用例确实需要两种不同的具体类型来区分实例(例如基于类型匹配),保留二者是合理的;否则建议合并到 ConcreteStateV3,在调用方实例化两份即可。请确认意图后决定是否保留。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/State/ConcreteStateV4.cs` around lines 1 - 59,
ConcreteStateV4 is a duplicate of ConcreteStateV3 (same properties
EnterCalled/ExitCalled/EnterFrom/ExitTo and methods
OnEnter/OnExit/CanTransitionTo); either remove ConcreteStateV4 and update tests
to use ConcreteStateV3 (instantiate multiple instances where type identity isn't
required) or merge any unique intent into ConcreteStateV3 and delete
ConcreteStateV4; search for ConcreteStateV4 references in tests and replace with
ConcreteStateV3 (or keep both only if tests rely on distinct runtime types),
ensuring OnEnter/OnExit/CanTransitionTo behavior is preserved.
GFramework.Core.Tests/Environment/TestEnvironment.cs (1)

20-23: 避免使用 new 仅为了放宽基类方法的可见性。

public new void Register(...) 通过隐藏而非重写来把基类的 protected Register 暴露为 public。虽然在本测试中不存在通过基类引用调用的场景,但这个模式仍然与 Meziantou.Analyzer 和 SonarQube 的可维护性规则相违背。

更推荐使用显式命名的测试辅助方法,语义更清晰:

♻️ 建议的改写
-    public new void Register(string key, object value)
+    public void RegisterForTest(string key, object value)
     {
         base.Register(key, value);
     }

或者在基类中提供 protected internal 入口,供测试程序集直接调用,而无需通过 new 覆盖访问级别。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@GFramework.Core.Tests/Environment/TestEnvironment.cs` around lines 20 - 23,
The TestEnvironment class should not use "new" to widen visibility of the base
protected Register; instead remove the shadowing method and add a clearly named
public test helper that delegates to the base method (e.g., add public void
RegisterForTest(string key, object value) that calls base.Register(key, value)),
or alternatively change the base Register to protected internal so tests can
call it directly; update references to call RegisterForTest (or use the newly
widened protected internal) and delete the public new void Register wrapper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md`:
- Around line 21-23: The file contains duplicated verification entries for the
same build command `dotnet build
GFramework.Core.Tests/GFramework.Core.Tests.csproj -c Release` (also noted at
the later entry that starts with the same command); remove the duplicate by
keeping a single consolidated entry for `GFramework.Core.Tests` Release build,
merge any differing notes (e.g., result: "成功;0 Warning(s)、0 Error(s)") into that
one entry, and drop the redundant block (the later `dotnet build`/`dotnet clean`
lines) so the active recovery document stays concise and unambiguous.

In `@GFramework.Core.Tests/Architectures/TestQueryV2.cs`:
- Around line 1-44: Update the XML <summary> for the Result property on
TestQueryV2 to reflect that it is init-only (settable only during object
initialization) rather than read/write; locate the Result property in class
TestQueryV2 and rephrase its summary to something like "Gets the query result
(set via object initializer during construction)". Also apply the same wording
change to TestCommandWithResultV2.Result so both summaries accurately describe
their init-only semantics.

In `@GFramework.Core.Tests/Architectures/TrackingPipelineBehavior.cs`:
- Around line 16-31: InvocationCount is a static mutable counter on the generic
TrackingPipelineBehavior and incrementing it with InvocationCount++ is not
atomic and causes races and test isolation problems; change the increment in
Handle to use Interlocked.Increment(ref InvocationCount) to make it atomic,
update the XML comments on InvocationCount and the Handle method to state the
thread-safety guarantees and that tests must reset InvocationCount (e.g., in a
[SetUp] method) before each test, and ensure InvocationCount remains an int so
Interlocked.Increment can be used.

In `@GFramework.Core.Tests/Command/TestAsyncCommand.cs`:
- Around line 5-7: Update the XML <summary> for the TestAsyncCommand class to
mention both consumers (CommandExecutorTests and AbstractAsyncCommandTests) and
adjust the cref references accordingly so the documentation reflects actual
reuse; specifically edit the XML summary that currently references <see
cref="CommandExecutorTests" /> to include or replace with both <see
cref="CommandExecutorTests" /> and <see cref="AbstractAsyncCommandTests" /> (or
reword to "used by CommandExecutorTests and AbstractAsyncCommandTests") so the
cref links point to the two test classes and the summary matches real usage of
TestAsyncCommand.

In `@GFramework.Core.Tests/Command/TestAsyncCommandWithExceptionV3.cs`:
- Around line 24-27: 当前在 TestAsyncCommandWithExceptionV3.cs 的
OnExecuteAsync(TestCommandInputV2) 中同步 throw
异常,若要将“异步方法返回故障任务”写得更显式,请把同步抛出替换为返回一个故障任务,例如将 throw new
InvalidOperationException(...) 改为 return Task.FromException(new
InvalidOperationException(...)),以使 OnExecuteAsync 明确返回失败的
Task;如果你想保留同步抛出以测试同步异常路径,则无需修改。

In `@GFramework.Core.Tests/Command/TestAsyncCommandWithResult.cs`:
- Around line 5-7: 更新 TestAsyncCommandWithResult 类的 XML 文档注释,将 <summary> 中对 <see
cref="CommandExecutorTests" /> 的专属引用扩展为同时包含 <see
cref="AbstractAsyncCommandTests" />
或改为泛化表述以表明此异步命令被多个测试套件复用;定位符号:TestAsyncCommandWithResult 类的类级注释(当前含 <summary> 和
<see cref="CommandExecutorTests" />),把 cref 改为 "<see cref="CommandExecutorTests"
/>, <see cref="AbstractAsyncCommandTests" />" 或改写为“用于多个异步命令测试(例如
CommandExecutorTests 和 AbstractAsyncCommandTests)”。

In `@GFramework.Core.Tests/Coroutine/ComplexQuery.cs`:
- Around line 44-47: GetContext currently suppresses nullable warnings with
_context! which can hide a missed SetContext call; change GetContext to
explicitly check _context for null and either (preferred) throw an informative
InvalidOperationException (e.g., "Context not initialized. Call SetContext
before using.") or, if you prefer API change, make GetContext return
IArchitectureContext? to reflect nullability; update callers/tests accordingly.
Ensure the check references the field _context and the method GetContext (and
mention SetContext in the exception message) so failures are clear and
null-safety is preserved.

In `@GFramework.Core.Tests/Coroutine/TestTimeSource.cs`:
- Line 8: The TestTimeSource class implements ITimeSource but has no intended
inheritance; mark the class declaration as sealed (change "public class
TestTimeSource : ITimeSource" to "public sealed class TestTimeSource :
ITimeSource") so it cannot be derived, satisfying Meziantou.Analyzer MA0053 and
preventing accidental subclassing.

In `@GFramework.Core.Tests/Environment/TestEnvironment.cs`:
- Around line 20-23: The TestEnvironment class should not use "new" to widen
visibility of the base protected Register; instead remove the shadowing method
and add a clearly named public test helper that delegates to the base method
(e.g., add public void RegisterForTest(string key, object value) that calls
base.Register(key, value)), or alternatively change the base Register to
protected internal so tests can call it directly; update references to call
RegisterForTest (or use the newly widened protected internal) and delete the
public new void Register wrapper.

In `@GFramework.Core.Tests/Query/TestAsyncComplexQuery.cs`:
- Around line 23-32: The TestAsyncQueryResult.DoubleValue name and its
assignment in OnDoAsync (currently input.Value * 3) are semantically
inconsistent; change the API to be clear by renaming
TestAsyncQueryResult.DoubleValue to TripleValue (update its XML comment
accordingly) and adjust all references and tests to use TripleValue, or
alternatively change the assignment in OnDoAsync to input.Value * 2 if you
intend it to be a true “double” (make the same change in the
TestAsyncQueryResult XML comment and any tests); locate the symbols
TestAsyncQueryResult, its DoubleValue property, and the
OnDoAsync(TestAsyncQueryInput) implementation to apply the change.

In `@GFramework.Core.Tests/Query/TestAsyncQueryResult.cs`:
- Around line 8-16: Update the XML summaries to reflect that the properties are
init-only: change the <summary> for the properties Value and DoubleValue in
TestAsyncQueryResult (and the Value property in TestAsyncQueryInput.cs) from
wording like "获取或设置" to "获取" or "获取并初始化" so the docs accurately describe that
these are assignable only at initialization; locate the properties named Value
and DoubleValue and adjust their <summary> text accordingly.

In `@GFramework.Core.Tests/State/ConcreteStateV4.cs`:
- Around line 1-59: ConcreteStateV4 is a duplicate of ConcreteStateV3 (same
properties EnterCalled/ExitCalled/EnterFrom/ExitTo and methods
OnEnter/OnExit/CanTransitionTo); either remove ConcreteStateV4 and update tests
to use ConcreteStateV3 (instantiate multiple instances where type identity isn't
required) or merge any unique intent into ConcreteStateV3 and delete
ConcreteStateV4; search for ConcreteStateV4 references in tests and replace with
ConcreteStateV3 (or keep both only if tests rely on distinct runtime types),
ensuring OnEnter/OnExit/CanTransitionTo behavior is preserved.

In `@GFramework.Core.Tests/State/TestAsyncState.cs`:
- Line 13: Rename the TestAsyncState property AllowTransition to
AllowTransitions to match ConcreteAsyncStateV2.AllowTransitions; update all
references within the class (notably the CanTransitionToAsync method) to use
AllowTransitions and adjust any test fixtures or usages that construct or
inspect TestAsyncState so they compile and maintain behavior.

In `@GFramework.Core.Tests/State/TestStateMachineSystemV5.cs`:
- Around line 16-20: The XML docs claim GetStates returns a read-only view but
the method returns IDictionary<Type, IState> (which is mutable) and exposes the
internal States field; change the API to return IReadOnlyDictionary<Type,
IState> from GetStates and return States directly if States implements
IReadOnlyDictionary or wrap States with a ReadOnlyDictionary<Type, IState> (or
alternatively, if mutability is intended, update the XML comment to describe a
mutable mapping). Update the GetStates method signature and its return
expression to use IReadOnlyDictionary<Type, IState> and ensure the States member
is not exposed mutably.

In `@GFramework.Core.Tests/State/TestStateV5_2.cs`:
- Around line 20-23: The parameter 'next' in CanTransitionTo(IState next) (and
the other two IState-taking interface implementations in TestStateV5_2) is
unused and triggers analyzer warnings; explicitly consume the parameter by
assigning it to a discard (e.g. "_ = next;") at the start of each method to
preserve current behavior while silencing the unused-parameter warning, leaving
the return logic unchanged and keeping the methods as the interface
implementations.

In `@GFramework.Core.Tests/Utility/TestContextUtilityV1.cs`:
- Around line 16-19: The Destroyed property currently has a public setter while
similar lifecycle flags Initialized and InitCalled use private setters; change
the Destroyed auto-property to use a private set (i.e., public bool Destroyed {
get; private set; }) so only the class can modify it, and ensure the lifecycle
method OnDestroy (or the override responsible for teardown) sets Destroyed
internally rather than relying on external callers to mutate it.
- Around line 11-24: 属性 Initialized 和 InitCalled 在 OnInit 中总被同时置为 true 且语义重复;请在
TestContextUtilityV1 中要么合并为单一属性(例如保留 Initialized 并删除 InitCalled,更新所有使用
InitCalled 的断言和引用为 Initialized),要么在 XML 注释中明确区分两者的语义(例如
一个表示“基类入口已执行”,另一个表示“派生/自定义 OnInit 钩子已调用”),并更新 OnInit
实现或测试路径以使两个属性能在语义上独立翻转;参照标识符:Initialized、InitCalled、OnInit 进行定位并同步修改所有相关引用和注释。

In `@GFramework.Core.Tests/Utility/TestContextUtilityV2.cs`:
- Around line 15-18: The Destroyed property currently has a public setter which
allows external code to mutate lifecycle state; change its definition to use a
private setter (i.e., public bool Destroyed { get; private set; }) to match
Initialized and CustomInitializationDone, and ensure all assignments to
Destroyed remain inside the lifecycle methods (e.g., OnDestroy) so only internal
logic updates the flag.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1147f96e-f47d-4a8e-8545-a4993752fcdc

📥 Commits

Reviewing files that changed from the base of the PR and between 7cfdd2c and f0a36de.

📒 Files selected for processing (86)
  • GFramework.Core.Tests/Architectures/AdditionalAssemblyNotification.cs
  • GFramework.Core.Tests/Architectures/AdditionalAssemblyNotificationHandlerRegistry.cs
  • GFramework.Core.Tests/Architectures/AdditionalAssemblyNotificationHandlerState.cs
  • GFramework.Core.Tests/Architectures/ArchitectureAdditionalCqrsHandlersTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureContextTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core.Tests/Architectures/ModuleBehaviorRequest.cs
  • GFramework.Core.Tests/Architectures/ModuleBehaviorRequestHandler.cs
  • GFramework.Core.Tests/Architectures/TestCommandV2.cs
  • GFramework.Core.Tests/Architectures/TestCommandWithResultV2.cs
  • GFramework.Core.Tests/Architectures/TestEventV2.cs
  • GFramework.Core.Tests/Architectures/TestModelV2.cs
  • GFramework.Core.Tests/Architectures/TestQueryV2.cs
  • GFramework.Core.Tests/Architectures/TestSystemV2.cs
  • GFramework.Core.Tests/Architectures/TestUtilityV2.cs
  • GFramework.Core.Tests/Architectures/TrackingPipelineBehavior.cs
  • GFramework.Core.Tests/Command/AbstractAsyncCommandTests.cs
  • GFramework.Core.Tests/Command/CommandExecutorTests.cs
  • GFramework.Core.Tests/Command/TestAsyncCommand.cs
  • GFramework.Core.Tests/Command/TestAsyncCommandChildV3.cs
  • GFramework.Core.Tests/Command/TestAsyncCommandV3.cs
  • GFramework.Core.Tests/Command/TestAsyncCommandWithExceptionV3.cs
  • GFramework.Core.Tests/Command/TestAsyncCommandWithResult.cs
  • GFramework.Core.Tests/Command/TestAsyncCommandWithResultChildV3.cs
  • GFramework.Core.Tests/Command/TestAsyncCommandWithResultV3.cs
  • GFramework.Core.Tests/Command/TestCommand.cs
  • GFramework.Core.Tests/Command/TestCommandInput.cs
  • GFramework.Core.Tests/Command/TestCommandInputV2.cs
  • GFramework.Core.Tests/Command/TestCommandWithResult.cs
  • GFramework.Core.Tests/Coroutine/ComplexQuery.cs
  • GFramework.Core.Tests/Coroutine/ComplexResult.cs
  • GFramework.Core.Tests/Coroutine/CoroutineSchedulerTests.cs
  • GFramework.Core.Tests/Coroutine/IntQuery.cs
  • GFramework.Core.Tests/Coroutine/QueryCoroutineExtensionsTests.cs
  • GFramework.Core.Tests/Coroutine/TestTimeSource.cs
  • GFramework.Core.Tests/Cqrs/DeterministicOrderNotification.cs
  • GFramework.Core.Tests/Cqrs/DeterministicOrderNotificationHandler.cs
  • GFramework.Core.Tests/Environment/EnvironmentTests.cs
  • GFramework.Core.Tests/Environment/TestEnvironment.cs
  • GFramework.Core.Tests/Events/EventBusTests.cs
  • GFramework.Core.Tests/Events/EventBusTestsEvent.cs
  • GFramework.Core.Tests/Extensions/ObjectExtensionsTests.cs
  • GFramework.Core.Tests/Extensions/TestClass.cs
  • GFramework.Core.Tests/Extensions/TestUnRegisterList.cs
  • GFramework.Core.Tests/Extensions/UnRegisterListExtensionTests.cs
  • GFramework.Core.Tests/Pool/ObjectPoolTests.cs
  • GFramework.Core.Tests/Pool/TestObjectPool.cs
  • GFramework.Core.Tests/Pool/TestPoolableObject.cs
  • GFramework.Core.Tests/Query/AsyncQueryExecutorTests.cs
  • GFramework.Core.Tests/Query/QueryExecutorTests.cs
  • GFramework.Core.Tests/Query/TestAsyncBooleanQuery.cs
  • GFramework.Core.Tests/Query/TestAsyncComplexQuery.cs
  • GFramework.Core.Tests/Query/TestAsyncQuery.cs
  • GFramework.Core.Tests/Query/TestAsyncQueryInput.cs
  • GFramework.Core.Tests/Query/TestAsyncQueryResult.cs
  • GFramework.Core.Tests/Query/TestAsyncQueryWithException.cs
  • GFramework.Core.Tests/Query/TestAsyncStringQuery.cs
  • GFramework.Core.Tests/Query/TestQuery.cs
  • GFramework.Core.Tests/Query/TestQueryInput.cs
  • GFramework.Core.Tests/Query/TestStringQuery.cs
  • GFramework.Core.Tests/Rule/ContextAwareTests.cs
  • GFramework.Core.Tests/Rule/TestContextAware.cs
  • GFramework.Core.Tests/State/ConcreteAsyncStateV2.cs
  • GFramework.Core.Tests/State/ConcreteStateV2.cs
  • GFramework.Core.Tests/State/ConcreteStateV3.cs
  • GFramework.Core.Tests/State/ConcreteStateV4.cs
  • GFramework.Core.Tests/State/ConditionalStateV2.cs
  • GFramework.Core.Tests/State/StateMachineExtensions.cs
  • GFramework.Core.Tests/State/StateMachineSystemTests.cs
  • GFramework.Core.Tests/State/StateMachineTests.cs
  • GFramework.Core.Tests/State/StateTests.cs
  • GFramework.Core.Tests/State/TestAsyncState.cs
  • GFramework.Core.Tests/State/TestContextAwareStateV5.cs
  • GFramework.Core.Tests/State/TestContextAwareStateV5_2.cs
  • GFramework.Core.Tests/State/TestStateMachineSystemV5.cs
  • GFramework.Core.Tests/State/TestStateV2.cs
  • GFramework.Core.Tests/State/TestStateV3.cs
  • GFramework.Core.Tests/State/TestStateV4.cs
  • GFramework.Core.Tests/State/TestStateV5.cs
  • GFramework.Core.Tests/State/TestStateV5_2.cs
  • GFramework.Core.Tests/State/TrackingStateV2.cs
  • GFramework.Core.Tests/Utility/AbstractContextUtilityTests.cs
  • GFramework.Core.Tests/Utility/TestContextUtilityV1.cs
  • GFramework.Core.Tests/Utility/TestContextUtilityV2.cs
  • ai-plan/public/analyzer-warning-reduction/todos/analyzer-warning-reduction-tracking.md
  • ai-plan/public/analyzer-warning-reduction/traces/analyzer-warning-reduction-trace.md
💤 Files with no reviewable changes (19)
  • GFramework.Core.Tests/Coroutine/QueryCoroutineExtensionsTests.cs
  • GFramework.Core.Tests/Extensions/ObjectExtensionsTests.cs
  • GFramework.Core.Tests/Environment/EnvironmentTests.cs
  • GFramework.Core.Tests/Events/EventBusTests.cs
  • GFramework.Core.Tests/Coroutine/CoroutineSchedulerTests.cs
  • GFramework.Core.Tests/Rule/ContextAwareTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureAdditionalCqrsHandlersTests.cs
  • GFramework.Core.Tests/Pool/ObjectPoolTests.cs
  • GFramework.Core.Tests/Query/QueryExecutorTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureModulesBehaviorTests.cs
  • GFramework.Core.Tests/Utility/AbstractContextUtilityTests.cs
  • GFramework.Core.Tests/Extensions/UnRegisterListExtensionTests.cs
  • GFramework.Core.Tests/State/StateMachineSystemTests.cs
  • GFramework.Core.Tests/State/StateMachineTests.cs
  • GFramework.Core.Tests/State/StateTests.cs
  • GFramework.Core.Tests/Architectures/ArchitectureContextTests.cs
  • GFramework.Core.Tests/Command/CommandExecutorTests.cs
  • GFramework.Core.Tests/Query/AsyncQueryExecutorTests.cs
  • GFramework.Core.Tests/Command/AbstractAsyncCommandTests.cs

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 27, 2026
- 修复测试辅助类型的只读暴露、空安全和线程安全问题

- 更新异步查询结果命名与init属性XML文档,保持语义一致

- 同步ai-plan恢复点与验证真值,记录PR298 nitpick跟进
@github-actions
Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
2159 2159 0 0 0 0 33.9s    ↓2.2s

Test Results

passed 2159 passed

Details

tests 2159 tests
clock 33.9s ↓2.2s
tool nunit
build CI - Build & Test arrow-right build-and-test link #996
pull-request Fix/analyzer warning reduction batch link #298

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
2150 0 3 4.7s

Fail Rate

Fail Rate 0.00%
Test 📝 Results 📊 Passed ✅ Failed ❌ Fail Rate (%) 📈
ILogAppender_Flush_Should_Raise_OnFlushCompleted_Only_Once 39 38 1 2.56    ↓0.07
RegisterMigration_During_Cache_Rebuild_Should_Not_Leave_Stale_Type_Cache 46 45 1 2.17    ↓0.05
Run_Should_Assign_Globally_Unique_Reference_Metadata_Member_Names 47 46 1 2.13    ↓0.04

build-and-test: Run #996

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
2159 2159 0 0 0 0 0 33.9s

🎉 All tests passed!

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
SendRequestAsync_Should_ResolveCqrsRuntime_OnlyOnce_When_AccessedConcurrently 47 4.1s 4.7s
Does_Not_Report_When_FieldInjectedModel_Is_Registered 47 2.1s 2.4s
Generates_Scene_Behavior_Boilerplate 47 1.9s 2.0s
CleanupDuringAcquire_Should_NotCauseRaceCondition 47 1.1s 1.1s
Append_ShouldNotBlock 47 1.0s 1.0s
Context_Caching_Should_Improve_Performance 47 781ms 791ms
PendingCount_ShouldReflectQueuedEntries 47 501ms 501ms
Cleanup_Should_NotRemoveActiveLocks 47 404ms 406ms
Cleanup_Should_RemoveUnusedLocks 47 401ms 402ms
Generates_Precise_Assembly_Type_Lookups_For_Inaccessible_External_Protected_Types 47 322ms 354ms

± Comparison with run #995 at da27766 | 🍂 No flaky tests detected across all runs. | ⏱️ Measured over 47 runs.

Github Test Reporter by CTRF 💚

@GeWuYou GeWuYou merged commit 6cc87a9 into main Apr 27, 2026
7 checks passed
@GeWuYou GeWuYou deleted the fix/analyzer-warning-reduction-batch branch April 27, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant